program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  fin : TextFile;
  i, n, p, k, l : integer;
  mass : array of integer;

begin
  writeln('Begin');
  readln;
  assignFile (fin, 'input.txt');
  reset (fin);
  readln (fin, n);
  setlength(mass, n);
  for i := 0 to n-1 do
    read(fin, mass[i]);
  l := mass[0];
  k := mass[0];
  for i := 0 to n-1 do
    if mass[i] > l then
      l := mass[i];
  for i := 0 to n-1 do
    if mass[i] < k then
      k := mass[i];
  p := k + l;
  writeln (p);
  readln;
  closeFile (fin);
  end.
end.
